import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate';


const state = { //要设置的全局访问的state对象

}

const getters = { //实时监听state值的变化(最新状态)
    breadListState() {
        return JSON.parse(sessionStorage.getItem('breadListStorage')) || [];
    }
}

const mutations = {
    breadListMutations(getters, list) {
        getters.breadListState = list;
        sessionStorage.setItem('breadListStorage', list);
    }
}
export default () => {
    return new Vuex.Store({
        plugins: [createPersistedState({
            storage: window.sessionStorage
        })],
        state,
        getters,
        mutations
    })
}
